// index.js
import {getpersonalizedList,getHotSongList,getOfficialList,getdjprogramList} from "../../api/home"
Page({

  data:{
    songList:[],
    OfficialList:[],
    personalizedList:[],
    programList:[]
  },
  
 // 获取每日推荐歌单的功能函数
 async getSongs(){
  try {
    let result = await  getOfficialList()
    this.setData({
      OfficialList:result.data.recommend
    })
  } catch (error) {
    console.log(error);
  }
 },
 // 获取热门歌单的功能函数
 async getHotSong(){
  try {
    let result = await getHotSongList()
    this.setData({
      songList:result.data.playlists
    })
  } catch (error) {
    console.log(error);
  }
 },
 // 获取歌曲推荐的功能函数
 async getpersonalized(){
  try {
    let result = await getpersonalizedList()
    this.setData({
      personalizedList:result.data.list.artists.slice(0,3)
    })
  } catch (error) {
    console.log(error);
  }
 },
 // 获取巅峰帮的功能函数
 async getdjprogram(){
  try {
    let result = await getdjprogramList()
    this.setData({
      programList:result.data.result.slice(0,3)
    })
  } catch (error) {
    console.log(error);
  }
 },

 onLoad(){
   this.getSongs()
   this.getHotSong()
   this.getpersonalized()
   this.getdjprogram()
 }

})
